using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Data;
using DTO;

using System.Data;

namespace Business
{
    public class ChiTietMatDoSuDungPhongService
    {




		//////////////////////////////////////////////////////////

 		                                                         

		//            Enter code your here                      //

		                                                         

		//////////////////////////////////////////////////////////

       static public DataTable ConvertListChiTietMatDoSuDungPhongDTOToDataTable( List<ChiTietMatDoSuDungPhongDTO> lst)
       {
               DataTable dt = new DataTable();
           dt.Columns.Add( "MaChiTietMatDoPhong");
           dt.Columns.Add( "MaPhong");
           dt.Columns.Add( "MaMatDoPhong");
           dt.Columns.Add( "SoNgayThue");
           dt.Columns.Add( "TyLe");
           for( int i = 0; i < lst.Count; i ++)
           {
               dt.Rows.Add(
                       lst[i].MaChiTietMatDoPhong,      
                       lst[i].MaPhong,      
                       lst[i].MaMatDoPhong,      
                       lst[i].SoNgayThue,      
                       lst[i].TyLe      
                   );
           }
               return dt;
       }
        static public int GetIdentity()
        {
            Data.ChiTietMatDoSuDungPhongRepository repo = new ChiTietMatDoSuDungPhongRepository();
            return repo.GetIdentity();
        }

        static public int Count()
        {
            return ChiTietMatDoSuDungPhongRepository.Count();
        }
        public static bool Them(ChiTietMatDoSuDungPhongDTO objDTO)
        {
                ChiTietMatDoSuDungPhongRepository repo = new ChiTietMatDoSuDungPhongRepository();
                return repo.Them(objDTO);
        }

        public static bool Xoa(int MaChiTietMatDoSuDungPhong, bool XoaKhoaNgoai=false)
        {
              ChiTietMatDoSuDungPhongRepository Repo = new ChiTietMatDoSuDungPhongRepository();
              return Repo.Xoa(MaChiTietMatDoSuDungPhong,XoaKhoaNgoai);
        }

        public static void CapNhat(ChiTietMatDoSuDungPhongDTO objDTO)
        {
            try
            {
                ChiTietMatDoSuDungPhongRepository Repo = new ChiTietMatDoSuDungPhongRepository();
                Repo.CapNhat(objDTO);
            }
            catch (System.Exception )
            {
            }
        }

        public static List<ChiTietMatDoSuDungPhongDTO> LayDanhSach()
        {
            List<ChiTietMatDoSuDungPhongDTO> lst = new List<ChiTietMatDoSuDungPhongDTO>();
            try
            {
                ChiTietMatDoSuDungPhongRepository obj = new ChiTietMatDoSuDungPhongRepository();
                lst = obj.LayDanhSach();
            }
            catch (System.Exception )
            {
            }
            return lst;
        }

        static public List<ChiTietMatDoSuDungPhongDTO> LayDanhSach(int Start, int Record)
        {
             Data.ChiTietMatDoSuDungPhongRepository repo = new ChiTietMatDoSuDungPhongRepository();
            return repo.LayDanhSach(Start, Record);
        }

        public static ChiTietMatDoSuDungPhongDTO LayTheoMa(int MaChiTietMatDoSuDungPhong)
        {
            ChiTietMatDoSuDungPhongDTO objDTO = new ChiTietMatDoSuDungPhongDTO();
            try
            {
                ChiTietMatDoSuDungPhongRepository Repo = new ChiTietMatDoSuDungPhongRepository();
                objDTO = Repo.LayTheoMa(MaChiTietMatDoSuDungPhong);
            }
            catch (System.Exception )
            {
            }
            return objDTO;
        }

//
//Khoa ngoai MatDoSuDungPhong
//
        static public List<ChiTietMatDoSuDungPhongDTO> LayDanhSachTheoMaMatDoSuDungPhong( int MaMatDoSuDungPhong)
        {
             Data.ChiTietMatDoSuDungPhongRepository repo = new ChiTietMatDoSuDungPhongRepository();
            return repo.LayDanhSachTheoMaMatDoSuDungPhong( MaMatDoSuDungPhong);
        }

        static public void XoaTheoMaMatDoSuDungPhong( int MaMatDoSuDungPhong, bool XoaKhoaNgoai=false)
        {
             Data.ChiTietMatDoSuDungPhongRepository repo = new ChiTietMatDoSuDungPhongRepository();
            repo.XoaTheoMaMatDoSuDungPhong( MaMatDoSuDungPhong,XoaKhoaNgoai);
        }


//
//Khoa ngoai Phong
//
        static public List<ChiTietMatDoSuDungPhongDTO> LayDanhSachTheoMaPhong( int MaPhong)
        {
             Data.ChiTietMatDoSuDungPhongRepository repo = new ChiTietMatDoSuDungPhongRepository();
            return repo.LayDanhSachTheoMaPhong( MaPhong);
        }

        static public void XoaTheoMaPhong( int MaPhong, bool XoaKhoaNgoai=false)
        {
             Data.ChiTietMatDoSuDungPhongRepository repo = new ChiTietMatDoSuDungPhongRepository();
            repo.XoaTheoMaPhong( MaPhong,XoaKhoaNgoai);
        }

    }
}

